
/**
 *  @param {object} obj 对象
 * @example
 * const data = {
 *   param1: 'value1',
 *   param2: 'value2'
 * };
 *
 * const urlParams = objectToUrlParams(data);
 * console.log(urlParams); // 输出：param1=value1&param2=value2
 */
export const objectToUrlParams = (obj) => {
  const params = new URLSearchParams()
  for (const key in obj) {
    if (Object.prototype.hasOwnProperty.call(obj, key)) {
      params.append(key, obj[key])
    }
  }
  return params.toString()
}
